#include<bits/stdc++.h>
using namespace std;
#define int  long long
const int N=1e6+10;
const int MOD = 1e9 + 7;
int a[N],pre[N];
int n;
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    int res=0;
    for(int i=1;i<=n;i++)
    {
        res = (res + res * a[i] + a[i]) % MOD;
        ans = 1ll  * res;
    }
    cout << res;
    return 0;
}